import request from './request'

const prepath = process.env.NODE_ENV == 'development' ? '/api' : ''
// 登录接口
export const loginApi = (data) => request.post(prepath + '/admin/auth/login', data)
// 刷新后获取用户信息
export const getUserByToken = () => request.post(prepath + '/admin/auth/getUserByToken');
// 获取商品列表
export const getGoodLists = (params) => request.get(prepath + '/admin/goods', {
  params
});

// 获取单个商品信息
export const getGoodInfo = (params) => request.get(prepath + '/admin/goods/info', {
  params
});

// 编辑单个商品信息
export const editGoodInfo = (data) => request.post(prepath + '/admin/goods/store', data);

// 获取品牌列表
export const getBrandLists = (params) => request.get(prepath + '/admin/brand', {
  params
});
// 保存品牌列表
export const addBrandLists = (data) => request.post(prepath + '/admin/brand/store', data);

// 删除品牌
export const destoryBrand = (data) => request.post(prepath + '/admin/brand/destory', data);

// 获取单个品牌详情
export const getBrandDetail = (params) => request.get(prepath + '/admin/brand/info', {
  params
});

// 获取分类列表
export const getCategoryLists = (params) => request.get(prepath + '/admin/category', {
  params
});
// 获取单个分类详情
export const getCategoryDetail = (params) => request.get(prepath + '/admin/category/info', {
  params
});
// 获取顶级分类
export const getTopCategory = (params) => request.get(prepath + '/admin/category/topCategory', {
  params
});
// 获取属性分类
export const getAttrInfo = (params) => request.get(prepath + '/admin/attribute/info', {
  params
});

// 保存属性
export const addAttrbute = (data) => request.post(prepath + '/admin/attribute/store', data);
// 保存分类
export const addCategory = (data) => request.post(prepath + '/admin/category/store', data);
// 保存分类
export const addTopic = (data) => request.post(prepath + '/admin/topic/store', data);
// 删除分类
export const destoryCategory = (data) => request.post(prepath + '/admin/category/destory', data);

// 图片上传
export const uploadGoodPic = (data) => request.post(prepath + '/admin/upload/goodNewPic', data);

// 获取属性列表
export const getAttributeLists = (params) => request.get(prepath + '/admin/attribute', {
  params
});
export const getTopicLists = (params) => request.get(prepath + '/admin/topic', {
  params
});
// 获取专题详情
export const getTopicInfo = (params) => request.get(prepath + '/admin/topic/info', {
  params
});
export const getOrderLists = (params) => request.get(prepath + '/admin/order', {
  params
});
// 报表数据
export const getStatData = (params) => request.get(prepath + '/admin/stat', {
  params
});
